<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>SimpleAgentTest</title>

<link rel="stylesheet"
	href="http://code.jquery.com/qunit/qunit-1.15.0.css">
<script src="http://code.jquery.com/qunit/qunit-1.15.0.js"></script>

<script src="../../main/js/util/JavaScriptAugments.js"></script>
<script src="../../main/js/util/Logger.js"></script>
<script src="../../main/js/util/ArrayUtilities.js"></script>
<script src="../../main/js/util/InputValidator.js"></script>

<script src="../../main/js/Phase.js"></script>
<script src="../../main/js/Team.js"></script>
<script src="../../main/js/Maneuver.js"></script>
<script src="../../main/js/ShipAction.js"></script>
<script src="../../main/js/Ship.js"></script>
<script src="../../main/js/RangeRuler.js"></script>
<script src="../../main/js/Weapon.js"></script>
<script src="../../main/js/Pilot.js"></script>
<script src="../../main/js/Position.js"></script>
<script src="../../main/js/SquadBuilder.js"></script>
<script src="../../main/js/Environment.js"></script>
<script src="../../main/js/Adjudicator.js"></script>
<script src="../../main/js/DamageCard.js"></script>
<script src="../../main/js/UpgradeCard.js"></script>
<script src="../../main/js/Token.js"></script>
<script src="../../main/js/PlanningAction.js"></script>
<script src="../../main/js/SimpleAgent.js"></script>

<script src="../../main/js/ui/ImageUtilities.js"></script>
<script src="../../main/js/ui/HumanAgent.js"></script>

<script>
    var LOGGER = new Logger();

    QUnit.test("SimpleAgent.getPlanningAction() Imperial", function(assert)
    {
        // Setup.
        var environment = Environment.createCoreSetEnvironment();
        var adjudicator = new Adjudicator();
        var name = "simpleAgent";
        var team = Team.IMPERIAL;
        var squadBuilder = CoreSetImperialSquadBuilder;
        var agent = new SimpleAgent(name, team, squadBuilder);

        var position0 = new Position(305, 20, 90);
        var token0 = environment.getTokenAt(position0);

        var position1 = new Position(610, 20, 90);
        var token1 = environment.getTokenAt(position1);

        var position2 = new Position(458, 895, -90);
        var token2 = environment.getTokenAt(position2);

        var result;
        var caller = {};
        caller.callback = function(planningAction)
        {
            LOGGER.info("caller.callback()");
            result = planningAction;

            // Verify.
            assert.ok(result);
            assert.ok(result.getManeuver(token0));
            assert.ok(result.getManeuver(token1));
            assert.ok(!result.getManeuver(token2));
        }

        // Run.
        agent.getPlanningAction(environment, adjudicator, caller.callback);
    });

    QUnit.test("SimpleAgent.getPlanningAction() Rebel", function(assert)
    {
        // Setup.
        var environment = Environment.createCoreSetEnvironment();
        var adjudicator = new Adjudicator();
        var name = "simpleAgent";
        var team = Team.REBEL;
        var squadBuilder = CoreSetRebelSquadBuilder;
        var agent = new SimpleAgent(name, team, squadBuilder);

        var position0 = new Position(305, 20, 90);
        var token0 = environment.getTokenAt(position0);
        var maneuver0 = Maneuver.STRAIGHT_1_STANDARD;

        var position1 = new Position(610, 20, 90);
        var token1 = environment.getTokenAt(position1);
        var maneuver1 = Maneuver.STRAIGHT_1_STANDARD;

        var position2 = new Position(458, 895, -90);
        var token2 = environment.getTokenAt(position2);
        var maneuver2 = Maneuver.STRAIGHT_1_STANDARD;

        var result;
        var caller = {};
        caller.callback = function(planningAction)
        {
            LOGGER.info("caller.callback()");
            result = planningAction;

            // Verify.
            assert.ok(result);
            assert.ok(!result.getManeuver(token0));
            assert.ok(!result.getManeuver(token1));
            assert.ok(result.getManeuver(token2), maneuver2);
        }

        // Run.
        agent.getPlanningAction(environment, adjudicator, caller.callback);
    });
</script>
</head>
<body>
	<div id="qunit"></div>
</body>
</html>
